Example of trouble w/ doubles.
public class ComparingFloats {
public void Compare()
{
double c =1.2+2.4;
if(c== 3.6)
{
System.out.println("c is 3.6");
}
else
{
System.out.println("c is not 3.6 but" + c);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ComparingFloats c=new ComparingFloats();
c.Compare();
}
}
|